package cate.game.role.farm.dailyfb;

import cate.common.table.d.GDDailyFb;
import cate.common.util.GameResult;
import cate.game.res.MixRes;
import cate.game.res.MixResItem;
import cate.game.role.Role;
import cate.game.role.farm.PlayTimes;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;
import org.springframework.data.annotation.Transient;

@NoteClass(value = "日常副本挑战次数记录")
public class DailyFbPlayTimes extends PlayTimes {
    @Transient
    @NoteField(value = "购买次数消耗")
    public transient MixRes extraCost;

    @Override
    /** 检测能否支付起购买次数 */
    protected GameResult checkAfford(Role role, int funcId, int use) {
        GameResult r = new GameResult();
        GameResult<MixResItem> er = checkCost(role);
        if (!er.ok()) {
            return er;
        }
        return r.success();
    }

    @Override
    public int getBasicFreeTimes(Role role, int funcId) {
        if (role == null || funcId <= 0) {
            return 0;
        }
        return GDDailyFb.PLAY_TIMES_FREE;
    }

    private GameResult<MixResItem> checkCost(Role role) {
        return extraCost.consume(role, null);
    }
}
